package LunaServer.user;

import com.google.gson.annotations.SerializedName;
import java.util.Objects;

/**
 * 用户数据结构类，定义了用户的基本信息
 * 类似于C++中的struct，用于规定用户数据的输出格式
 */
public class UserData {
    @SerializedName("id")
    private int id;
    
    @SerializedName("username")
    private String username;
    
    @SerializedName("email")
    private String email;
    
    @SerializedName("age")
    private int age;
    
    @SerializedName("is_active")
    private boolean isActive;
    
    /**
     * 默认构造函数
     */
    public UserData() {
    }
    
    /**
     * 带参数的构造函数
     */
    public UserData(int id, String username, String email, int age, boolean isActive) {
        this.id = id;
        this.username = username;
        this.email = email;
        this.age = age;
        this.isActive = isActive;
    }
    
    // Getter方法
    public int getId() {
        return id;
    }
    
    public String getUsername() {
        return username;
    }
    
    public String getEmail() {
        return email;
    }
    
    public int getAge() {
        return age;
    }
    
    public boolean isActive() {
        return isActive;
    }
    
    // Setter方法
    public void setId(int id) {
        this.id = id;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    public void setAge(int age) {
        this.age = age;
    }
    
    public void setActive(boolean active) {
        isActive = active;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserData userData = (UserData) o;
        return id == userData.id &&
                age == userData.age &&
                isActive == userData.isActive &&
                Objects.equals(username, userData.username) &&
                Objects.equals(email, userData.email);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(id, username, email, age, isActive);
    }
    
    @Override
    public String toString() {
        return "UserData{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", email='" + email + '\'' +
                ", age=" + age +
                ", isActive=" + isActive +
                '}';
    }
}